#pragma once;

#include <vector>

#include "common.h"
#include "rigidbody.h"
#include "collision_primitive.h"
#include "SceneObject.h"

namespace TorPhysix
{

	class Box;
	class Ball;

	class PhysicsObject : public SceneObject
	{
	public:

		PhysicsObject() : SceneObject()
		{
		}

		virtual ~PhysicsObject(){  }

		TorPhysix::CollisionPrimitive *collisionPrimitive;

		virtual Vec3f vGetPosition() { return collisionPrimitive->body->getPosition(); }

		virtual void vSetPosition(const Vec3f &newPos) { 
			collisionPrimitive->body->setPosition(newPos); 
			collisionPrimitive->body->calculateDerivedData(); 
			// Calc internals so static objs (others collide with it, it doesn't collide against them) to geo and visuals sync up
			collisionPrimitive->calculateInternals(); 
		}

		virtual Quatf vGetOrientation() { return collisionPrimitive->body->getOrientation(); };

		virtual void vSetOrientation(const Quatf &newOrient)
		{
			collisionPrimitive->body->setOrientation(newOrient);  
			collisionPrimitive->body->calculateDerivedData(); 

			// Calc internals so static objs (others collide with it, it doesn't collide against them) to geo and visuals sync up
			collisionPrimitive->calculateInternals();  
		};

		void update(TorPhysix::real duration)
		{
			collisionPrimitive->body->integrate(duration);
			collisionPrimitive->calculateInternals();
		}

		void getGLTransform(float mtx[16] ) const { collisionPrimitive->body->getGLTransform(mtx); } 

		bool vIsManipulator() const { return false; }

		virtual void vRenderShadow() = 0;
		virtual void vRenderDebug() = 0;

		virtual void vSetState(real x, real y, real z, Quatf orientation, Vec3f collisionSize, real mass, Vec3f acceleration) = 0;

		virtual bool isSphere() { return false; }
		virtual bool isBox() { return false; }

		virtual void acceptVisitor( PhysicsObject& visitor, CollisionData* cData ) = 0;
		virtual void collideAgainst( Box& box, CollisionData* cData ) = 0;
		virtual void collideAgainst( Ball& ball, CollisionData* cData ) = 0;
	protected:

		
		


	};

}

